//
//  YZOrganizationInfoVC.m
//  VET
//
//  Created by 刘文靖 on 2018/6/27.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZOrganizationInfoVC.h"

@interface YZOrganizationInfoVC ()
@property (weak, nonatomic) IBOutlet UITextField *organizationTF;
@end

@implementation YZOrganizationInfoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNavigationItem];
}

- (void)setupNavigationItem{
    self.title = @"职业信息";
    UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 36, 25)];
    [rightButton setTitle:@"保存" forState:UIControlStateNormal];
    [rightButton setTitleColor:kColorWithHex(0x007AFF) forState:UIControlStateNormal];
    [rightButton setTitleColor:kColorWithHex(0xcecece) forState:UIControlStateDisabled];
    rightButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:18];
    [rightButton addTarget:self action:@selector(saveOrganizationInfo) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *righBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = righBarButtonItem;
    RACSignal *organizationSignal = [self.organizationTF.rac_textSignal map:^id(NSString *str) {
        return @(str.length);
    }];
    RAC(rightButton, enabled) = organizationSignal;
}

- (void)saveOrganizationInfo{
    //1,上传到后台
    //2,返回个人职业信息页 更新工作机构
    if (self.organizationResultBlock) {
        self.organizationResultBlock(self.organizationTF.text);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:YES];
}


@end
